// 服务端渲染
const router = require('express').Router()

// 导入中间件
const { getBannerList, getUserInfo, getUserMessage,getShopList,getCartList } = require('../middleware/pages')

// 专门配置各种页面的路由请求
router.get('/index', getBannerList, getUserInfo, (req, res) => 
{ res.render('index.html', { list: req.banner, nickname: req.nickname }) })
router.get('/login', (req, res) => res.render('login.html', {}))
router.get('/register', (req, res) => res.render('register.html', {}))
router.get('/cart', getCartList,(req, res) => 
{res.render('cart.html', {list:req.cartlist,selected:req.selected,selectNum:req.selectNum, 
    selectPrice:req.selectPrice  })})
router.get('/list', getShopList,(req, res) => 
{res.render('list.html', {list:req.shoplist,totalpage:req.totalpage,current:req.current})})
router.get('/rpwd', (req, res) => res.render('rpwd.html', {}))
router.get('/self',getUserMessage, (req, res) => 
{res.render('self.html', {list:req.list})})

module.exports = router